package com.baizhi.service.impl;

import com.baizhi.dao.AdminLogDAO;
import com.baizhi.entity.AdminLog;
import com.baizhi.service.AdminLogService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class AdminLogServiceImpl implements AdminLogService {

    @Autowired
    private AdminLogDAO adminLogDAO;

    @Override
    public PageInfo<AdminLog> show(int page, int limit) {
        PageHelper.startPage(page, limit);
        List<AdminLog> adminLogs = adminLogDAO.selectAll();
        PageInfo<AdminLog> pageInfo = new PageInfo<>(adminLogs);
        return pageInfo;
    }

    @Override
    public void add(AdminLog adminLog) {
        adminLogDAO.insertAdminLog(adminLog);
    }

    @Override
    public void remove(int id) {
        adminLogDAO.deleteById(id);
    }

    @Override
    public void deleteMany(int[] ids) {
        adminLogDAO.deleteMany(ids);
    }
}
